home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.arch.embedded,comp.lang.c
- Subject: Re: Using malloc of C on embedded system?
- Date: 31 Mar 1996 12:48:30 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4jmr2uINN3cm@keats.ugrad.cs.ubc.ca>
- References: <4jml7h$cbc@castor.usc.edu>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4jml7h$cbc@castor.usc.edu>,
- Stannon Yen <chuitiny@castor.usc.edu> wrote:
- >Hello,
- >
- > This is just a general question. Is it possible to use C function
- >malloc and free on system that has no OS? How can I setup the memory
- >pool for dynamic allocation/deallocation of memory?
-
- Here is where the ISO standard's distinction between a ``hosted'' and
- ``freestanding'' implementation comes in handy.
-
- Presumably, the embedded development environment is freestanding, which means
- that you are allowed to define your own malloc() function with external
- linkage.
-
- How you do this is entirely up to you. You may wish to do research into
- dynamic storage allocation methods. The Art of Computer Programming volumes by
- Knuth are a good starting point.
-
- The implementation will depend a great deal on the overall architecture of the
- embedded system. For example, if it has a protected kernel that manages virtual
- address spaces, this will obviously have an impact over how you implement
- malloc. Your memory use might be divided between per-process memory
- _allocation_ scheme with your malloc() which draws on an underlying memory
- _management_ scheme implemented in the kernel.
-
- Or, you could make malloc the only memory allocation function. The simplest
- case is the machine with some flat amount of RAM after the end of your OS. You
- take this and do heap allocation within it: the sample malloc() allocation
- given in K&R2 (the chapter covering UNIX system interfaces) might be something
- worth looking at.
- --
-
-